﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZealousTTS.Common.Extensions;
using ZealousTTS.Domain;
using ZealousTTS.Web.ViewModels;
using ZealousTTS.Web.Utility;
using AutoMapper;

namespace ZealousTTS.Web.Areas.Private.Controllers
{
    public class HomeController : BaseController
    {
		private ZealousTTSEntities _Context;
        
		#region Constructors
		public HomeController()
		{
			_Context = new ZealousTTSEntities();
		}

		public HomeController(UserViewModel currentUser)
			: base(currentUser)
        {
			_Context = new ZealousTTSEntities();
        }
		#endregion Constructors

		#region Action Methods
        public ActionResult Index()
        {
            return View();
        }
         //<summary>
         //Gets a Home from Database to edit
         //</summary>
         //<param name="id"></param>
         //<returns></returns>
        //public ActionResult Edit(int id = 0)
        //{
        //    Home entity = id == 0 ? new Home() : _Context.Homes.FirstOrDefault(P => P.ID == id);            
        //    HomeViewModel viewModel = Mapper.Map<Home, HomeViewModel>(entity);             
        //    return View(viewModel);
        //}

        // <summary>
        // Saves Home Information into the Database
        // </summary>
        // <param name="viewModel"></param>
        // <returns></returns>
        //[HttpPost]
        //public ActionResult Edit(HomeViewModel viewModel)
        //{
        //    if (!ModelState.IsValid)
        //        return View(viewModel);

        //    Home entity = null; 
        //    if (viewModel.ID == 0)
        //    {
        //        entity = new Home();
        //        _Context.AddToHomes(entity);
        //    }
        //    else
        //        entity = _Context.Homes.FirstOrDefault(P => P.ID == viewModel.ID);

        //    entity = Mapper.Map<HomeViewModel, Home>(viewModel, entity);
        //    _Context.SaveChanges();
        //    return RedirectToAction("Index");        
        //}		
        #endregion Action Methods

        #region Helper Methods

        #endregion
    }
}
